//
//  MovieTableViewCell.m
//  豆瓣电影app
//
//  Created by 洛洛大人 on 16/6/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "MovieTableViewCell.h"
#import "MovieModel.h"
#import "UIImageView+WebCache.h"

#define kWidth self.contentView.frame.size.width
#define kHeight self.contentView.frame.size.height

@interface MovieTableViewCell()
@property(nonatomic, retain)UIImageView *movieImageView;
@property(nonatomic, retain)UILabel *nameLabel;
@property(nonatomic, retain)UIImageView *llImageView;


@end

@implementation MovieTableViewCell

-(void)dealloc{
    [_movieImageView release];
    [_nameLabel release];
    [super dealloc];
    
    
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        
        self.llImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bg_eventlistcell.png"]];
        self.llImageView.frame = CGRectMake(20, 20, self.contentView.frame.size.width + 20, self.contentView.frame.size.width * 0.4);
      
        [self.contentView addSubview:self.llImageView];
        
                                   
        
        
        self.nameLabel = [[UILabel alloc]init];
        [self.llImageView addSubview:self.nameLabel];
        [self.nameLabel release];
        
        self.movieImageView = [[UIImageView alloc]init];
        [self.llImageView addSubview:self.movieImageView];
        [self.movieImageView release];
        
   }
    
    return self;


}


-(void)layoutSubviews {
    
    [super layoutSubviews];
    
  
    self.movieImageView.frame = CGRectMake(30, 15, kWidth * 0.2, kHeight - 50);
    
    
    
    self.nameLabel.frame = CGRectMake(_movieImageView.frame.size.width + 80, 40, kWidth * 0.8,  kHeight * 0.4);
}


-(void)setCellModel:(MovieModel *)cellModel{
    
    if (_cellModel != cellModel) {
        [_cellModel release];
        _cellModel = [cellModel retain];
    }
    NSURL *url = [NSURL URLWithString:cellModel.pic_url];
    

    
    [self.movieImageView sd_setImageWithURL:url];
    
  
    
    self.nameLabel.text = cellModel.movieName;
    
    
    
}











@end
